#ifndef __BSP_AHT21_DRIVER_H
#define __BSP_AHT21_DRIVER_H

#include "stdint.h"
#include "stdio.h"

/*上层iic接口 */
typedef struct{
    int8_t          (*pfiic_init)         (void* iic_bus);
    int8_t          (*pfiic_deinit)       (void* iic_bus);
    void            (*pfiic_start)        (void* iic_bus);
    void            (*pfiic_stop)         (void* iic_bus);
    int8_t          (*pfiic_wait_ack)     (void* iic_bus);
    void            (*pfiic_send_ack)     (void* iic_bus);
    void            (*pfiic_send_no_ack)  (void* iic_bus);
    void            (*pfiic_send_byte)    (void* iic_bus, uint8_t sendByte);
    uint8_t         (*pfiic_receive_byte) (void* iic_bus);

}iic_driver_interface_t;

/*上层操作系统延时函数 */
typedef struct{
    //操作系统延时函数
    //void (*rtos_yield)(uint32_t ms);
    void (*os_delay_ms)(uint32_t ms);
}yield_interface_t;

/*上层中断屏蔽函数*/
#ifndef HARDWARE_IIC
typedef struct{
    void (*pftaskENTER_CRITICAL)(void);
    void (*pftaskEXIT_CRITICAL) (void);
}irq_interface_t;
#endif
/*集合结构体*/
typedef struct bsp_aht21_driver bsp_aht21_driver_t; // 前置声明
typedef struct bsp_aht21_driver{

    uint32_t id;  //设备id

    iic_driver_interface_t  *psiic_interface;
    yield_interface_t       *psyield_interface;
    irq_interface_t         *psirq_interface;

    //本层函数
    int8_t (*pfaht_init)   (bsp_aht21_driver_t *bsp_aht21_driver);
    int8_t (*pfaht_deinit) (bsp_aht21_driver_t *bsp_aht21_driver);
    int8_t (*pfread_id)    (bsp_aht21_driver_t *bsp_aht21_driver);
    int8_t (*pfaht_read)   (bsp_aht21_driver_t *bsp_aht21_driver, float *humi, float *temp);
    int8_t (*pfsleep)      (bsp_aht21_driver_t *bsp_aht21_driver);
    int8_t (*pfwakeup)     (bsp_aht21_driver_t *bsp_aht21_driver);

}bsp_aht21_driver_t;

//构造函数
int8_t  inst_driver(  bsp_aht21_driver_t        *bsp_aht21_driver, 
                      iic_driver_interface_t    *iic_interface,
                      yield_interface_t         *psyield_interface,
                      irq_interface_t           *psirq_interface);
#endif
